package com.uchiha.nova.mainService.wrapper;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.uchiha.nova.core.tool.support.BaseEntityWrapper;
import com.uchiha.nova.core.tool.node.ForestNodeMerger;
import com.uchiha.nova.core.model.entity.CompanyBusinessLicenseEntity;
import com.uchiha.nova.core.model.vo.CompanyBusinessLicenseVO;
import com.uchiha.nova.mainService.service.ICompanyBusinessLicenseService;
import com.uchiha.nova.core.tool.util.SpringUtil;

import java.util.List;
import java.util.stream.Collectors;
/**
 * 公司营业执照信息 包装类,返回视图层所需的字段
 *
 * @author Uchihashiamu
 */
public class CompanyBusinessLicenseWrapper extends BaseEntityWrapper<CompanyBusinessLicenseEntity, CompanyBusinessLicenseVO>  {
  
  ICompanyBusinessLicenseService companyBusinessLicenseService = SpringUtil.getBean(ICompanyBusinessLicenseService.class);
  
	public static CompanyBusinessLicenseWrapper build() {
		return new CompanyBusinessLicenseWrapper();
 	}

	@Override
	public CompanyBusinessLicenseVO entityVO(CompanyBusinessLicenseEntity companyBusinessLicenseEntity) {
		CompanyBusinessLicenseVO companyBusinessLicenseVO = new CompanyBusinessLicenseVO();
		BeanUtil.copyProperties(companyBusinessLicenseEntity, companyBusinessLicenseVO);

		return companyBusinessLicenseVO;
	}
	public List<CompanyBusinessLicenseVO> listVO(List<CompanyBusinessLicenseEntity> list) {
		List<CompanyBusinessLicenseVO> collect = list.stream().map(item -> {
            CompanyBusinessLicenseVO companyBusinessLicenseVO = new CompanyBusinessLicenseVO();
		    BeanUtil.copyProperties(item, companyBusinessLicenseVO);			
			return companyBusinessLicenseVO;
		}).collect(Collectors.toList());
		return collect;
    // return ForestNodeMerger.merge(collect);
	}
  
  	@Override
	public IPage<CompanyBusinessLicenseVO> pageVO(IPage<CompanyBusinessLicenseEntity> pages) {
		IPage<CompanyBusinessLicenseVO> page = pages.convert(item->{
            CompanyBusinessLicenseVO companyBusinessLicenseVO = new CompanyBusinessLicenseVO();
		    BeanUtil.copyProperties(item, companyBusinessLicenseVO);			
			return companyBusinessLicenseVO;
		});
		return page;
	}
}
